package cn.zhl.algorithm._3_并查集.impl;

/**
 * @program: demos
 * @description: 基于高度的优化，合并的时候查看两边的根节点下面子元素的高度
 * @author: 刘振华
 * @create: 2020-06-11 19:00
 **/
public class QuickUnionHeightPathSplit extends QuickUnionHeight {
	public QuickUnionHeightPathSplit(int capacity){
		super(capacity);
	}

	@Override
	public int find(int v) {
		rangeCheck(v);
		while (parent[v] != v){
			v = parent[v];
			parent[v] = parent[parent[v]];
		}
		return v;
	}

}
